package Test;

import java.util.Scanner;

public class test {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        Student stu=new Student();

        while (true) {
            try {
                System.out.println("请输入学生姓名");
                String name = sc.nextLine();
                stu.setName(name);

                System.out.println("请输入学生年龄");
                String agestr = sc.nextLine();
                int age=Integer.parseInt(agestr);
                stu.setAge(age);
                break;
            } catch (NumberFormatException e) {
                e.printStackTrace();
            }
              catch (RuntimeException e) {
                e.printStackTrace();
            }
        }
        System.out.println(stu);
    }
}
